import {request} from "@/network/request";

export function getBlogByPage(currentPage, limit) {
    return request({
        url: "blogs",
        method: "get",
        params: {
            currentPage,
            limit
        }
    })
}

export function getBlogById(id) {
    return request({
        url: "/blog",
        method: "get",
        params: {
            id
        }
    })
}

export function getBlogByTitle(title) {
    return request({
        url: "/blog/search",
        method: "get",
        params: {
            title
        }
    })
}

export function getBlogsByCategory(category) {
    return request({
        url: "/blog/category",
        method: "get",
        params: {
            category
        }
    })
}

export function getBlogSize() {
    return request({
        url: "/blogSize",
        method: "get"
    })
}

export function getCategories() {
    return request({
        url: "/blog/categories",
        method: "get"
    })
}

export function addBlog(blog) {
    return request({
        url: "/blog/add",
        method: "post",
        data: blog
    })
}

export function updateBlog(blog) {
    return request({
        url: "/blog/update",
        method: "post",
        data: blog
    })
}

export function deleteBlog(id) {
    return request({
        url: "/blog/delete",
        method: "post",
        params: {
            id
        }
    })
}